package dl.bukkit.myststus.configuration;

import org.bukkit.configuration.InvalidConfigurationException;
import org.bukkit.configuration.file.YamlConfiguration;

import java.io.File;
import java.io.IOException;

public abstract class SubConfiguration extends YamlConfiguration implements IConfiguration{

    private final String path;
    private final File config;

    public SubConfiguration(String path) {
        this.path = path;
        this.config = ConfigurationManager.builderFile(path);
    }

    @Override
    public void saveConfig() {
        if (! config.exists()) {
            ConfigurationManager.saveResource(path);
        }
    }

    @Override
    public void loadConfig() {
        try {
            this.load(this.config);
        } catch (IOException | InvalidConfigurationException e) {
            e.printStackTrace();
        }
    }
}
